package com.orange.score.model.league;

import android.util.Log;
import com.orange.score.constants.ScoreType;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;

public class LeagueManager
{
  public static final int LEAGUE_FROM_REALTIME_INDEX = 2;
  public static final int LEAGUE_FROM_REALTIME_MATCH = 1;
  public static final int LEAGUE_FROM_REPOSITORY = 3;
  private static final String TAG = "LeagueManager";
  String currentRound;
  Set<String> filterLeagueSet;
  List<League> leagueList = new ArrayList();
  Map<String, League> leagueMap = new HashMap();
  String totalRound;

  public LeagueManager()
  {
    this.filterLeagueSet = new HashSet();
  }

  public List<League> filterLeagueByCountryId(String paramString)
  {
    ArrayList localArrayList2;
    ArrayList localArrayList1 = new ArrayList();
    if ((this.leagueList == null) || (this.leagueList.size() == 0))
    {
      localArrayList2 = null;
      return localArrayList2;
    }
    Iterator localIterator = this.leagueList.iterator();
    while (true)
    {
      League localLeague;
      do
      {
        while (!(localIterator.hasNext()))
          localArrayList2 = localArrayList1;
        localLeague = (League)localIterator.next();
      }
      while (!(localLeague.getCountryId().equals(paramString)));
      localArrayList1.add(localLeague);
    }
  }

  public List<League> findAllLeagues()
  {
    return this.leagueList;
  }

  public List<League> findAllTopLeagues()
  {
    ArrayList localArrayList = new ArrayList();
    Iterator localIterator = this.leagueList.iterator();
    while (true)
    {
      League localLeague;
      do
      {
        if (!(localIterator.hasNext()))
          return localArrayList;
        localLeague = (League)localIterator.next();
      }
      while (!(localLeague.isTop));
      localArrayList.add(localLeague);
    }
  }

  public List<League> findDanchangLeagues()
  {
    ArrayList localArrayList = new ArrayList();
    Iterator localIterator = this.leagueList.iterator();
    while (true)
    {
      League localLeague;
      do
      {
        if (!(localIterator.hasNext()))
          return localArrayList;
        localLeague = (League)localIterator.next();
      }
      while (localLeague.type != ScoreType.DANCHANGE.intValue());
      localArrayList.add(localLeague);
    }
  }

  public List<League> findJingcaiLeagues()
  {
    ArrayList localArrayList = new ArrayList();
    Iterator localIterator = this.leagueList.iterator();
    while (true)
    {
      League localLeague;
      do
      {
        if (!(localIterator.hasNext()))
          return localArrayList;
        localLeague = (League)localIterator.next();
      }
      while (localLeague.type != ScoreType.JINGCAI.intValue());
      localArrayList.add(localLeague);
    }
  }

  public League findLeagueById(String paramString)
  {
    return ((League)this.leagueMap.get(paramString));
  }

  public List<League> findZucaiLeagues()
  {
    ArrayList localArrayList = new ArrayList();
    Iterator localIterator = this.leagueList.iterator();
    while (true)
    {
      League localLeague;
      do
      {
        if (!(localIterator.hasNext()))
          return localArrayList;
        localLeague = (League)localIterator.next();
      }
      while (localLeague.type != ScoreType.ZUCAI.intValue());
      localArrayList.add(localLeague);
    }
  }

  public Set<String> getFilterLeagueSet()
  {
    return this.filterLeagueSet;
  }

  public String[] getLeagueRound()
  {
    String[] arrayOfString = new String[2];
    arrayOfString[0] = this.totalRound;
    arrayOfString[1] = this.currentRound;
    return arrayOfString;
  }

  public boolean hasLeagueData()
  {
    int i;
    if ((this.leagueList != null) && (this.leagueList.size() > 0))
      i = 1;
    while (true)
    {
      return i;
      i = 0;
    }
  }

  public void setFilterLeagueSet(Set<String> paramSet)
  {
    this.filterLeagueSet = paramSet;
  }

  public void setLeagueList(List<League> paramList)
  {
    this.leagueList = paramList;
  }

  public void updateDataFromStringList(String[] paramArrayOfString, int paramInt)
  {
    int i;
    if ((paramArrayOfString == null) || (paramArrayOfString.length == 0));
    do
    {
      return;
      this.leagueList.clear();
      i = 0;
    }
    while (i >= paramArrayOfString.length);
    String[] arrayOfString = paramArrayOfString[i].split("\\^");
    Object localObject = null;
    switch (paramInt)
    {
    default:
    case 1:
    case 3:
    case 2:
    }
    while (true)
    {
      Log.d("LeagueManager", "add league = " + ((League)localObject).toString());
      this.leagueList.add(localObject);
      this.leagueMap.put(((League)localObject).getLeagueId(), localObject);
      while (true)
      {
        while (true)
        {
          while (true)
          {
            while (true)
            {
              while (true)
              {
                while (true)
                  ++i;
                if (arrayOfString.length >= 3)
                  break;
                Log.w("LeagueManager", "updateDataFromStringList but field count not enough, count = " + arrayOfString.length);
              }
              localObject = new League(arrayOfString[1], arrayOfString[0], arrayOfString[2]);
            }
            if (arrayOfString.length >= 6)
              break;
            Log.w("LeagueManager", "updateLeagueDataFromStringList but field count not enough, count = " + arrayOfString.length);
          }
          String str1 = arrayOfString[0];
          String str2 = arrayOfString[1];
          String str3 = arrayOfString[2];
          String str4 = arrayOfString[3];
          String str5 = arrayOfString[4];
          List localList = Arrays.asList(arrayOfString[5].split(","));
          localObject = new League();
          ((League)localObject).setLeagueId(str1);
          ((League)localObject).setCountryId(str2);
          ((League)localObject).setName(str3);
          ((League)localObject).setShortName(str4);
          ((League)localObject).setType(Integer.parseInt(str5));
          ((League)localObject).setSeasonList(localList);
        }
        if (arrayOfString.length >= 3)
          break;
        Log.w("LeagueManager", "updateOddsLeagueDataFromStringList but field count not enough, count = " + arrayOfString.length);
      }
      localObject = new League(arrayOfString[0], arrayOfString[1], arrayOfString[2]);
    }
  }

  public void updateLeagueRound(String paramString1, String paramString2)
  {
    this.totalRound = paramString1;
    this.currentRound = paramString2;
  }
}